package com.top.art.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.top.art.bo.AllocationPageBO;
import com.top.art.bo.DistributeBO;
import com.top.art.bo.TeachersBO;
import com.top.art.manager.TeacherAllocationManager;
import com.top.art.vo.AllocationVO;
import com.top.art.vo.ResVO;
import com.top.art.vo.TeacherAllocationVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 阅卷老师分配表 前端控制器
 * </p>
 *
 * @author hjh
 * @since 2020 -10-05
 */
@RestController
@RequestMapping("/allocation")
public class TeacherAllocationController {

    /**
     * manager
     */
    @Resource
    private TeacherAllocationManager teacherAllocationManager;

    /**
     * Page res vo.
     *
     * @param bo the bo
     * @return the res vo
     */
    @PostMapping(value = "page")
    public ResVO<Page<AllocationVO>> page(@Validated @RequestBody AllocationPageBO bo) {
        Page<AllocationVO> page = teacherAllocationManager.page(bo);
        return new ResVO<>(page);
    }


    /**
     * Teachers res vo.
     *
     * @param bo the bo
     * @return the res vo
     */
    @PostMapping(value = "teachers")
    public ResVO<TeacherAllocationVO> teachers(@Validated @RequestBody TeachersBO bo) {
        TeacherAllocationVO userInfoVOS = teacherAllocationManager.teachers(bo);
        return new ResVO<>(userInfoVOS);
    }

    /**
     * Examination res vo.
     *
     * @return the res vo
     */
    @GetMapping(value = "examinationCount")
    public ResVO<Integer> examinationCount() {
        int count = teacherAllocationManager.examinationCount();
        return new ResVO<>(count);
    }

    /**
     * Paper count res vo.
     *
     * @return the res vo
     */
    @GetMapping(value = "paperCount")
    public ResVO<Integer> paperCount() {
        int count = teacherAllocationManager.paperCount();
        return new ResVO<>(count);
    }

    /**
     * Distribute res vo.
     *
     * @param bo the bo
     * @return the res vo
     */
    @PostMapping(value = "distribute")
    public ResVO<Boolean> distribute(@Validated @RequestBody DistributeBO bo) {
        boolean result = teacherAllocationManager.distribute(bo);
        return new ResVO<>(result);
    }
}
